package jp.co.sopia.util;

import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class UtilFunctions {
	public static final String EMPTY_STRING = "";
	
	/**
	 * Gets value child from element - match case
	 * @param e
	 * @param name
	 * @return
	 */
	public static String getValueChildFromElement(Element e, String name) {
		if (e == null || EMPTY_STRING.equals(name))
			return EMPTY_STRING;
		NodeList childs = e.getElementsByTagName(name);
		if(childs == null) return EMPTY_STRING;
		return childs.item(0).getTextContent() == null ? EMPTY_STRING : childs.item(0).getTextContent();
	}
}
